/**
 * 商品管理相关接口
 */
import { Request, Response } from 'express';

const Data = [
  {name:'name',type:'2',desc:'ms1',delivery:2,price:99,count:3,ptrs:10,id:2},
  {name:'na2me',type:'32',desc:'m4s1',delivery:12,price:919,count:13,ptrs:120,id:1}
];

const getGoodList = (req: Request, res: Response) => {
  res.json(Data);
};

const updateGoodList = (req:Request,res:Response) => {
  Data.forEach((i,index) => {
    if(i.id === req.body.id){
      Data[index] = {...i,...req.body}
    }
  })
  res.status(200).json({
    success:true,
    data:Data
  })
  // res.end('OK')
}

export default {
  'GET /api/goods/list': getGoodList,
  'POST /api/goods/update': updateGoodList
};
